<template>
	<view class="uni-tabbar" :style="{'background-color':backgroundColor}">
		<view @tap="clickItem(index)" class="item" v-for="(item, index) in list" :key="index">
			<image class="icon" :src="active === item.name ? item.active : item.icon" mode="widthFix"></image>
			<view class="text">{{item.title}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{
						title: '消息',
						name: 'index',
						icon: require('../static/tabbar_icon/msg.png'),
						active: require('../static/tabbar_icon/msg_active.png'),
						path: '/pages/index/index'
					},
					{
						title: '联系人',
						name: 'userlist',
						icon: require('../static/tabbar_icon/user.png'),
						active: require('../static/tabbar_icon/user_active.png'),
						path: '/pages/userlist/userlist'
					},
					{
						title: '我的',
						name: 'csuser',
						icon: require('../static/tabbar_icon/my.png'),
						active: require('../static/tabbar_icon/my_active.png'),
						path: '/pages/csuser/csuser'
					}
				]
			};
		},
		props: {
			active: {
				type: String,
				default: ''
			},
			backgroundColor: {
				type: String,
				default: '#FFFFFF'
			}
		},
		methods: {
			clickItem (index) {
				this.$emit('clickLeft', index)
			}
		}
	}
</script>

<style>
	.uni-tabbar{
		height: 56px;
		display: flex;
		justify-content: space-around;
		align-items: center;
		flex-shrink:0;
		box-shadow: 0 -1px 6px #ccc;
	}
	.uni-tabbar .item{
		font-size: 0;flex-grow: 1;height:100%;display: flex;
		flex-direction: column;align-items: center;justify-content: center;
	}
	.uni-tabbar .item .text{
		font-size: 12px;line-height: 12px;color:#666666;
	}
	.uni-tabbar .item .icon{
		width: 25px;
	}
</style>
